package com.isasc.demo.pooled.datasource;

import lombok.extern.slf4j.Slf4j;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * @author: ywy
 * @date: 2022-10-17
 * @desc:
 *
 */
@Slf4j
public class Jdbc {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://localhost/foodie-shop-dev",
                "root",
                "rootroot"
        );
        PreparedStatement statement = connection.prepareStatement("select * from orders");
        ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()){
            log.info(resultSet.getString("id"));
        }
        resultSet.close();;
        statement.close();;
        connection.close();
    }
}
